import 'package:flutter/material.dart';

import 'package:flutter/cupertino.dart';
import 'package:progress_dialog/progress_dialog.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:loading_indicator_view/loading_indicator_view.dart';
import 'package:aweb5/util/NaviUtil.dart';
class DialogUtil {
  static showdialog(BuildContext context, Widget child, double height) async {
    await showDialog(
      barrierDismissible: false,
        context: context,
        builder: (con) {
          return Dialog(
            shape:
                RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
            child: Container(
              height: height,
              width: 100,
              decoration:
                  BoxDecoration(borderRadius: BorderRadius.circular(20)),
              child: Padding(
                padding: EdgeInsets.all(20),
                child: child,
              ),
            ),
          );
        });
  }

  static showdialog1(BuildContext context, Widget child, double height) async {
    await showDialog(
        barrierDismissible: false,
        context: context,
        builder: (con) {
          return Dialog(
            shape:
            RoundedRectangleBorder(borderRadius: BorderRadius.circular(4)),
            child: Container(
              height: height,
//              width: 100,
              decoration:
              BoxDecoration(borderRadius: BorderRadius.circular(20)),
              child: Padding(
                padding: EdgeInsets.all(0),
                child: child,
              ),
            ),
          );
        });
  }

  static showdialognopadding(BuildContext context, Widget child, double width,double height) async {
    await showDialog(
      barrierDismissible: false,
        context: context,
        builder: (con) {
          return
            Center(
              child:
              Container(
                height: height,
              width: width,
                decoration:
                BoxDecoration(borderRadius: BorderRadius.circular(20),color: Color(0xffffffff)),
                child: child,
              )
              ,

            )
            ;
        });
  }

//  static ProgressDialog showLoadingDialog(BuildContext context){
//    final ProgressDialog pr = ProgressDialog(context,type: ProgressDialogType.Normal, isDismissible: false, showLogs: true);
//    pr.show();
//    return pr;
//  }

  static hideDialog(ProgressDialog dialog){
    if(dialog.isShowing()){
      dialog.hide();
    }
  }

  static showloadingdialog(BuildContext context) async{

    await showDialog(
        barrierDismissible: false,
        context: context,
        builder: (con) {
      return
        Center(
          child:
          Container(
            height: ScreenUtil().setHeight(90),
            width: ScreenUtil().setWidth(90),
            decoration:
            BoxDecoration(borderRadius: BorderRadius.circular(5),color: Color(0xffffffff)),
            child:Center(child: LineSpinFadeLoaderIndicator(ballColor: Colors.blue,)) ,
          )
          ,

        )
      ;
    });

  }

  static pop(BuildContext context){
    NaviUtil.pop(context);
  }


}
